import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import moment from 'moment';

export const columns: BasicColumn[] = [
  {
    title: '车牌号',
    dataIndex: 'plateNumber',
  },
  {
    title: '品牌',
    dataIndex: 'brand',
  },
  {
    title: '型号',
    dataIndex: 'model',
  },
  {
    title: '颜色',
    dataIndex: 'color',
  },
  {
    title: '车辆类别',
    dataIndex: 'type',
  },
  {
    title: '购买日期',
    dataIndex: 'purchaseDate',
    customRender: ({ record }) => {
      const time = record.purchaseDate;
      return time ? moment(time).format('YYYY-MM-DD') : '-';
    },
  },
  {
    title: '保险单号码',
    dataIndex: 'policyNumber',
  },
  {
    title: '车辆状况',
    dataIndex: 'carCondition',
  },
  {
    title: '车辆状态',
    dataIndex: 'status',
    customRender: ({ record }) => {
      return record.status === 0 ? '空闲' : '借用';
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'status',
    label: '状态',
    component: 'Select',
    colProps: { span: 8 },
    componentProps: {
      options: [
        {
          value: 0,
          label: '空闲',
        },
        {
          value: 1,
          label: '借用',
        },
      ],
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'plateNumber',
    label: '车牌号',
    component: 'Input',
    required: true,
    componentProps: {
      placeholder: '请输入车牌号',
    },
  },
  {
    field: 'brand',
    label: '品牌',
    component: 'Input',
    componentProps: {
      placeholder: '请输入品牌',
    },
  },
  {
    field: 'model',
    label: '型号',
    component: 'Input',
    componentProps: {
      placeholder: '请输入型号',
    },
  },
  {
    field: 'color',
    label: '颜色',
    component: 'Input',
    componentProps: {
      placeholder: '请输入颜色',
    },
  },
  {
    field: 'type',
    label: '类别',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入类别',
    },
  },
  {
    field: 'purchaseDate',
    label: '购买时间',
    component: 'DatePicker',
    componentProps: {
      placeholder: '请选择购买时间',
      valueFormat: 'X',
    },
  },
  {
    field: 'carCondition',
    label: '车辆状况',
    component: 'Input',
    componentProps: {
      placeholder: '请输入车辆状况',
    },
  },
  {
    field: 'status',
    label: '状态',
    component: 'Select',
    componentProps: {
      options: [
        {
          value: 0,
          label: '空闲',
        },
        {
          value: 1,
          label: '借用',
        },
      ],
    },
  },
];
